<template>
	<view>
		<baseForm :column.sync="column" @submitFun="submitFun" :submitStatus="submitDisable" :button="button"></baseForm>
		<progressBox :auditVos="auditVos" dictcode="dict_audit_status"></progressBox>
		<view class="buttons" v-if="getApprovalShow('applyStatus')">
			<button size="mini" class="middleButton" @click="pass('调代课', itemData)">通过</button>
			<button size="mini" class="middleButton" @click="unpass('调代课', itemData)">不通过</button>
		</view>
	</view>
</template>

<script>
import baseForm from '@/wxcomponents/form/form.vue';
import pickerModule from '@/wxcomponents/form/picker.vue';
import { format, dectList } from '@/libs/common.js';
import progressBox from '@/wxcomponents/commonLayout/progressLevel.vue';
import userMixins from '@/libs/userMixins.js';
import approvalMixins from '@/libs/approvalMixins.js';
import formMixins from '@/libs/formMixins.js';
export default {
	mixins: [userMixins, approvalMixins, formMixins],
	data() {
		let self = this;
		return {
			itemData: '',
			button: {
				hide: true
			},
			column: [
				{
					label: '任教课程',
					name: 'courseName',
					type: 'normalInput',
					required: true,
					disabled: true,
					value: '',
					text: '请选择'
				},
				{
					label: '任教班级',
					name: 'className',
					type: 'normalInput',
					disabled: true,
					required: true,
					value: '',
					text: '请选择',
					range: []
				},
				{
					label: '原授课日期',
					name: 'beforeDate',
					type: 'picker',
					mode: 'date',
					disabled: true,
					required: true,
					value: '',
					start: format('YY-mm-dd', new Date()),
					text: '请选择'
				},

				{
					label: '原授课节次',
					name: 'beforeTimeIndexShow',
					type: 'normalInput',
					disabled: true,
					required: true,
					value: '',
					text: ''
				},
				{
					label: '调代课老师',
					name: 'afterTeacherName',
					type: 'normalInput',
					singleChoice: true,
					required: true,
					disabled: true,
					value: '',
					text: '',
					url: '/modules/department/departmentMenu',
					originUrl: '/modules/substituteCoruse/changeCoruse',
					chooseItems: []
				},
				{
					label: '拟调整日期',
					name: 'afterDate',
					type: 'picker',
					mode: 'date',
					disabled: true,
					required: true,
					value: '',
					text: '请选择',
					start: format('YY-mm-dd', new Date())
				},
				{
					label: '调代授课程',
					name: 'afterCourseName',
					type: 'normalInput',
					mode: 'selector',
					disabled: true,
					required: true,
					value: '',
					text: '请选择'
				},
				{
					label: '拟调整节次',
					name: 'afterTimeIndexShow',
					type: 'normalInput',
					disabled: true,
					required: true,
					value: ''
				},
				{
					label: '代课原因',
					name: 'changeReasonType',
					type: 'picker',
					mode: 'selector',
					disabled: true,
					required: true,
					value: '',
					text: '请选择',
					range: self.findOneDictList('dict_course_change_reasontype')
				},
				{
					label: '',
					name: 'changeReasonDetail',
					type: 'picker',
					mode: 'selector',
					disabled: true,
					required: true,
					value: '',
					text: '请选择',
					range: self.findOneDictList('dict_course_change_reasondetail')
				},
				{
					label: '',
					name: 'changeReasonRemark',
					type: 'normalInput',
					disabled: true,
					// required: true,
					value: '',
					hidden:true
				}
			],
			detailId: '',
			auditVos: ''
		};
	},
	async onLoad(option) {
		this.itemData = JSON.parse(option.data);
		this.getDetail();
	},
	methods: {
		async getDetail() {
			let self = this;
			let caseMap = [
				{
					condition() {
						// 详情
						return self.itemData.detailType == 'detail';
					},
					async func() {
						let resp = await self.$http.get({
							url: `/edu/wechat/classCourseChange/detail/${self.itemData.id}`
						});
						self.assignFormDataToViewModel(resp.result, self.column);
						self.auditVos = resp.result.auditVoList;
					}
				},
				{
					condition() {
						// 审批
						return self.itemData.detailType == 'approval';
					},
					async func() {
						let resp = await self.$http.get({
							url: `/edu/wechat/classCourseChange/detail/${self.itemData.id}`
						});
						self.assignFormDataToViewModel(resp.result, self.column);
						self.auditVos = resp.result.auditVoList;
					}
				}
			];
			let findOne = caseMap.filter(item => {
				return item.condition();
			})[0];
			if (!findOne) {
				alert(`getDetail方法出错`);
			}
			findOne.func();
		}
	},
	components: {
		baseForm,
		pickerModule,
		progressBox
	},
	computed:{
		leaveReasonName() {
			let column = this.column[9];
			return column.text
		}
	},
	watch: {
		leaveReasonName:{
			handler(n){
				this.column[10].hidden = n != '其他';
			}
		}
	}
};
</script>

<style></style>
